package com.railway.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.railway.bean.LoseCreditUser;
import com.railway.bean.Vo;
import com.railway.dao.LoseCreditDao;
import com.railway.dao.impl.LoseCreditDaoImpl;
import com.railway.util.JSONUtil;
@WebServlet("/LoserCreditAdmin.do")
public class LoserCreditAdminServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		int pageNum,pageSize;
		if(req.getParameter("page") == null) {
			pageNum = 1;
		}else {
			pageNum = Integer.parseInt(req.getParameter("page"));
		}
		

		if(req.getParameter("limit") == null) {
			pageSize = 10;
		}else {
			pageSize = Integer.parseInt(req.getParameter("limit"));
		}
		LoseCreditDao lcu = new LoseCreditDaoImpl();
		List<LoseCreditUser> list = lcu.selectUserAllByAdmin(pageNum, pageSize);
		Vo<LoseCreditUser> vo = new Vo();
		vo.setCode(0);
		vo.setMsg("success");
		vo.setData(list);
		vo.setCount(lcu.selectAllUser());
		JSONUtil.responJSOn(resp, vo);
	}
	

}
